<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <a-form
          ref="formRef"
          size="small"
          :model="pageData"
          layout="inline"
          v-if="permissionStore.hasPermisson('zjjzcx.cx')"
        >
          <!-- <a-form-item label-col-flex="80px" label="组别">
                        <a-cascader :style="{ width: '267px' }" class="bacClass" v-model="pageData.groupId" :options="pageData.gsList"
                            @focus="getFirmGroup" :value-key="pageData.groupId" allow-clear />
                    </a-form-item> -->
          <a-form-item label="员工工号" label-col-flex="80px" :style="{ width: '315px' }">
            <!-- <a-select popup-container="html"  style="width:200px" class="bacClass" v-model="pageData.checkStaffCode" @focus="focusSel3" allow-clear>
                            <a-option v-for="item in pageData.xmList" :value="item.checkStaffCode">
                                {{ item.checkStaffCode }}
                            </a-option>
                        </a-select> -->
            <a-input
              allow-clear
              class="bacClass"
              placeholder=""
              v-model="pageData.checkStaffCode"
              @press-enter="huiche"
            />
          </a-form-item>
          <a-form-item label="员工姓名" label-col-flex="80px" :style="{ width: '315px' }">
            <!-- <a-select popup-container="html"  style="width:200px" class="bacClass" v-model="pageData.checkStaff" @focus="focusSel3" allow-clear>
                            <a-option v-for="item in pageData.xmList" :value="item.checkStaff">
                                {{ item.checkStaff }}
                            </a-option>
                        </a-select> -->
            <a-input
              allow-clear
              class="bacClass"
              placeholder=""
              v-model="pageData.checkStaff"
              @press-enter="huiche"
            />
          </a-form-item>
          <a-form-item label="坯布编号" label-col-flex="80px" :style="{ width: '315px' }">
            <!-- <a-select popup-container="html"  style="width:200px" class="bacClass" v-model="pageData.greigeCode" @focus="focusSel1" allow-clear
                            @change="pbChange">
                            <a-option v-for="item in pageData.pbList" :value="item.id">
                                {{ item.greigeCode }}
                            </a-option>
                        </a-select> -->
            <a-input
              allow-clear
              class="bacClass"
              placeholder=""
              v-model="pageData.greigeCode"
              @press-enter="huiche"
            />
          </a-form-item>
          <a-form-item label="坯布名称" label-col-flex="80px" :style="{ width: '315px' }">
            <!-- <a-select popup-container="html"  style="width:195px" class="bacClass" v-model="pageData.greigeName" @focus="focusSel2" allow-clear>
                            <a-option v-for="item in pageData.pbmcList" :value="item['greigeName']">
                                {{ item["greigeName"] }}
                            </a-option>
                        </a-select> -->
            <a-input
              allow-clear
              class="bacClass"
              placeholder=""
              v-model="pageData.greigeName"
              @press-enter="huiche"
            />
          </a-form-item>
          <a-form-item label="日期" label-col-flex="80px" :style="{ width: '315px' }">
            <!-- <a-date-picker  popup-container="html"  style="width:125px" class="bacClass" v-model="pageData.billDate" @press-enter="huiche" />至
                        <a-date-picker  popup-container="html"  style="width:125px" class="bacClass" v-model="pageData.billDate2" @press-enter="huiche" /> -->
            <a-range-picker
              popup-container="html"
              class="bacClass"
              @select="onSelect"
              @clear="onClear"
            />
          </a-form-item>
          <a-form-item label="织布单号" label-col-flex="80px" :style="{ width: '315px' }">
            <a-input
              allow-clear
              class="bacClass"
              placeholder=""
              v-model="pageData.planOrderCode"
              @press-enter="huiche"
            />
          </a-form-item>
        </a-form>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up
            v-if="headerShow"
            @click="headerShow = false"
            :strokeWidth="2"
            :size="18"
          />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
      <div class="my-tool-bar">
        <Toolbar
          :items="pageData.btnList"
          @add="addHandler"
          @del="deleteHandler"
          @select="selectHandler"
          @export="exports"
          @import="importHandler"
          @excel="downloadHandler"
        >
        </Toolbar>
      </div>
    </template>
    <template #pageTabel>
      <!-- <a-tabs   :justify="true">
                <a-tab-pane> -->
      <AgGridVuesCopys
        :rowHeight="33"
        :headerHeight="33"
        :suppressCopyRowsToClipboard="true"
        rowSelection="multiple"
        @grid-ready="gridReady"
        style="height: calc(100% - 45px)"
        :defaultColDef="defaultColDef"
        class="ag-theme-alpine"
        :rowData="pageData.tableList"
        :columnDefs="tc"
        :localeText="localeText1"
        @FilterChanged="FilterChangeds"
      >
      </AgGridVuesCopys>
      <paginationCopys
        :total="total"
        show-total
        show-jumper
        show-page-size
        :page-size="size"
        :current="page"
        @change="PageSize"
        @page-size-change="change1"
        style="justify-content: center"
        :page-size-options="pagingList1"
      />
      <!-- </a-tab-pane>
            </a-tabs> -->
    </template>

    <a-drawer
      ok-text="保存"
      cancel-text="关闭"
      :drawer-style="{ zIndex: 9999 }"
      :mask-closable="false"
      :width="400"
      :ok-loading="pageData.pageLoading"
      :visible="pageData.showAdd"
      unmountOnClose
      @ok="sideOk"
      @cancel="pageData.showAdd = false"
    >
      <template #title>
        {{ pageData.sideTitle }}
      </template>
    </a-drawer>
  </pageTabelLayout>
</template>

<script lang="ts">
  import { post, get } from '@/api/http'
  import {
    useTable,
    useRowKey,
    useTableColumn,
    usePagination,
    useRowSelection,
  } from '@/hooks/table'
  import emitter from '@/hooks/useEventBus'
  import { ref, reactive, onMounted, toRefs } from 'vue'
  import Toolbar from '@/components/Toolbar.vue'
  import { Form, Message, Modal } from '@arco-design/web-vue'
  import { FormInstance } from '@arco-design/web-vue/es/form'
  import { baseURL } from '../../../api/axios.config'
  import axios from 'axios'
  import filedownload from 'js-file-download'
  import usePermission from '@/store/modules/permission'
  import PageTabelLayout from '@/components/pageTabelLayout.vue'
  import { AnyARecord } from 'dns'

  import { localeText } from '@/api/aggridZw'
  import { pagingList } from '@/api/paging'
  import { EXELTABLE } from '@/utils/exportEXCEL'
  import { slicing } from '@/utils/caseFrimAndSecRig'
  interface BrandInfo {
    id: any
    remark: string | undefined
    createName: string | undefined
    createTime: string | undefined
    updateName: string | undefined
    updateTime: string | undefined
    deleteState: any
    obsoleteState: any
    serial: any
    disassemblePrice: any
    unit: any
  }

  export default {
    name: 'CheckinInquiry',
    setup() {
      const pagingList1: any = ref(pagingList)
      const total = ref(10)
      const page = ref(1)
      const size = ref(10)
      function PageSize(val: any) {
        page.value = val
        doRefresh()
      }
      function change1(val: any) {
        size.value = val
        doRefresh()
      }
      const toFixedNum = (num: number) => {
        return parseFloat(num.toFixed(2))
      }
      const headerShow = ref<boolean>(true)
      //查询方法
      function doRefresh() {
        pageData.pageLoading = true
        post({
          url: '/pieceData/dutymachineSalary/getCheckClothWage',
          data: {
            page: page.value,
            size: size.value,
            userCode: pageData.checkStaffCode,
            userName: pageData.checkStaff,
            greyCode: pageData.greigeCode,
            greyName: pageData.greigeName,
            planOrderCode: pageData.planOrderCode,
            beginDate: pageData.billDate,
            endDate: pageData.billDate2,
          },
        })
          .then(({ data, code }: any) => {
            if (code === 200) {
              pageData.tableList = data.list
              gridOption.value.setRowData(data.list)
              total.value = data.total
              countRow(pageData.tableList)
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
      }

      const { selectedRowKeys, onSelectionChange } = useRowSelection()
      const pagination = usePagination(doRefresh)
      const table = useTable()
      const rowKey = useRowKey('id')
      const tableColumns = [
        {
          title: '公司',
          key: 'companyName',
          dataIndex: 'companyName',
          width: 150,
        },
        {
          title: '员工工号',
          key: 'userCode',
          dataIndex: 'userCode',
          width: 150,
        },
        {
          title: '员工姓名',
          key: 'userName',
          dataIndex: 'userName',
          width: 150,
        },
        {
          title: '班组',
          key: 'shift',
          dataIndex: 'shift',
          slotName: 'shift',
          width: 150,
        },
        {
          title: '织布单号',
          key: 'planOrderCode',
          dataIndex: 'planOrderCode',
          width: 150,
        },
        {
          title: '机台号',
          key: 'machineCode',
          dataIndex: 'machineCode',
          width: 150,
        },
        {
          title: '坯布编号',
          key: 'greyCode',
          dataIndex: 'greyCode',
          width: 200,
        },
        {
          title: '坯布名称',
          key: 'greyName',
          dataIndex: 'greyName',
          width: 200,
        },
        {
          title: '验布日期',
          key: 'billDate',
          dataIndex: 'billDate',
          width: 200,
        },
        {
          title: '值机重量',
          key: 'checkWeight',
          dataIndex: 'checkWeight',
          width: 200,
        },
        {
          title: '个人次布重量',
          key: 'fabricWeight',
          dataIndex: 'fabricWeight',
          width: 200,
        },
        {
          title: '个人验后重量',
          key: 'posteriorWeight',
          dataIndex: 'posteriorWeight',
          width: 200,
        },
        // {
        //   title: '匹号',
        //   key: 'horses',
        //   dataIndex: 'horses',
        //   width: 200,
        // },
        // {
        //     title: "磅布重量",
        //     key: "",
        //     dataIndex: "",
        //     width: 200
        // },
        // {
        //   title: '次布重量',
        //   key: 'fabricWeight',
        //   dataIndex: 'fabricWeight',
        //   width: 200,
        // },
        // {
        //   title: '验后重量',
        //   key: 'actualWeight',
        //   dataIndex: 'actualWeight',
        //   width: 200,
        // },
        {
          title: '单价',
          key: 'weaverPrice',
          dataIndex: 'weaverPrice',
          width: 200,
        },
        {
          title: '值机金额',
          key: 'weaverMoney',
          dataIndex: 'weaverMoney',
          width: 200,
        },
        // {
        //   title: '补贴单价',
        //   key: 'subsidyPrice',
        //   dataIndex: 'subsidyPrice',
        //   width: 200,
        // },
        // {
        //   title: '补贴金额',
        //   key: 'subsidyMoney',
        //   dataIndex: 'subsidyMoney',
        //   width: 200,
        // },
        {
          title: '总金额',
          key: 'totalMoney',
          dataIndex: 'totalMoney',
          width: 200,
        },
      ]
      let tc: any[] = tableColumns.map((o) => {
        let obj = {
          headerName: o.title,
          field: o.key,
          pinned: o['fixed'],
          tooltipField: o.key,
        }
        if (o.slotName === 'shift') {
          obj['resizable'] = false
          obj['filter'] = false
          obj['sortable'] = false
          obj['cellRenderer'] = {
            template: `<span v-if="a==0">白班</span><span v-if="a==1">夜班</span>`,
            setup(props: any) {
              return {
                a: props.params.data.shift,
              }
            },
          }
        }
        if (o.key === 'totalMoney') {
          obj['cellRenderer'] = {
            template: `<div>{{a}}</div>`,
            setup(props: any) {
              return {
                a: ref(toFixedNum(props.params.data.weaverMoney + props.params.data.subsidyMoney)),
              }
            },
          }
        }

        return obj
      })

      let a = [
        {
          showRowGroup: 'hide_def',
          headerName: '',
          checkboxSelection: true,
          headerCheckboxSelection: true,
          pinned: 'left',
          width: 50,
          resizable: false,
          filter: false,
          sortable: false,
          minWidth: 50,
          maxWidth: 50,
          lockPosition: 'left',
        },
      ]
      tc = a.concat(tc)

      const pageData = reactive<{
        showAdd: boolean
        sideTitle: string
        dropDownData: any
        nameList: []
        pageLoading: boolean
        typeList: []
        dropDownData1: any
        rHeight: any
        btnList: any[]
        isEdit: boolean
        UnitList: any[]
        pbList: any[]
        pbmcList: []
        greigeName: any
        planOrderCode: any
        gsList: any[]
        groupId: any
        group: any
        ghList: any[]
        xmList: any[]
        checkStaff: any
        checkStaffCode: any
        billDate: any
        billDate2: any
        greigeCode: any
        hejishuzu: any
        tableList: any[]
      }>({
        tableList: [],
        nameList: [],
        showAdd: false,
        sideTitle: '新增拆纱单价基础资料',
        dropDownData: '',
        pageLoading: false,
        typeList: [],
        dropDownData1: '',
        rHeight: 0,
        btnList: [],
        isEdit: false,
        UnitList: [],
        pbList: [],
        pbmcList: [],
        greigeName: '',
        planOrderCode: '',
        gsList: [],
        groupId: null,
        group: '',
        ghList: [],
        xmList: [],
        checkStaff: '',
        checkStaffCode: '',
        billDate: '',
        billDate2: '',
        greigeCode: '',
        hejishuzu: [],
      })

      onMounted(() => {
        // 切换tap到本页面执行的方法
        emitter.on('CheckinInquiry', () => {
          doRefresh()
        })
      })

      let cxbl = {}
      //查询
      const selectHandler = () => {
        page.value = 1
        doRefresh()
      }
      const queryData = reactive({
        disassemblePrice: '',
      })
      const addHandler = () => {
        for (var key in dataForm) {
          if (key === 'id') {
            dataForm[key] = null
          } else {
            dataForm[key] = ''
          }
        }
        pageData.showAdd = true
        pageData.sideTitle = '新增拆纱单价基础资料'
      }
      const dataForm = reactive<BrandInfo>({
        id: null,
        remark: '',
        createName: '',
        createTime: '',
        updateName: '',
        updateTime: '',
        deleteState: 0,
        obsoleteState: '',
        serial: 0,
        disassemblePrice: '',
        unit: '',
      })

      // 表格准备事件
      const gridOption = ref()
      const gridReady = (params: any) => {
        gridOption.value = params.api
      }

      const formRef = ref<FormInstance>()
      const sideOk = () => {
        formRef.value?.validate().then((err) => {
          if (!err) {
            formRef.value?.validate().then((err) => {
              if (!err) {
                pageData.pageLoading = true
                if (pageData.sideTitle === '新增拆纱单价基础资料') {
                  post({
                    url: '/pieceData/disassemblePrice/insert',
                    data: [dataForm],
                  })
                    .then((res: any) => {
                      if (res.code === 200) {
                        formRef.value?.resetFields()
                        pageData.showAdd = false
                        Message.success({
                          content: '新增成功',
                          duration: 5000,
                        })
                      } else {
                        Message.error({
                          content: res.message,
                          duration: 5000,
                        })
                      }
                      doRefresh()
                    })
                    .finally(() => {
                      doRefresh()
                      pageData.pageLoading = false
                    })
                } else {
                  post({
                    url: '/pieceData/disassemblePrice/update',
                    data: [dataForm],
                  })
                    .then((res: any) => {
                      if (res.code === 200) {
                        formRef.value?.resetFields()
                        pageData.showAdd = false
                        Message.success({
                          content: '修改成功',
                          duration: 5000,
                        })
                      } else {
                        Message.error({
                          content: res.message,
                          duration: 5000,
                        })
                      }
                      //doRefresh();
                    })
                    .finally(() => {
                      doRefresh()
                      pageData.pageLoading = false
                    })
                }
              }
            })
          }
        })
      }
      const deleteHandler = () => {
        if (gridOption.value.getSelectedRows().length === 0) {
          Message.error('请先勾选')
          return
        }
        Modal.confirm({
          title: '系统提示',
          content: '确认删除选中的数据?',
          onOk() {
            pageData.pageLoading = true
            post({
              url: '/pieceData/disassemblePrice/delete',
              data: gridOption.value.getSelectedRows().map((o: any) => {
                return o.id
              }),
            })
              .then(({ code, data }: any) => {
                if (code === 200) {
                  Message.success({
                    content: '删除成功',
                    duration: 5000,
                  })
                  pagination.page = 1
                  doRefresh()
                } else {
                  Message.error({
                    content: '修改失败',
                    duration: 5000,
                  })
                }
              })
              .finally(() => {
                pageData.pageLoading = false
              })
          },
        })
      }
      const editHandler = (record: BrandInfo) => {
        //循环对象 赋值
        for (let key in record) {
          dataForm[key] = record[key]
        }
        pageData.sideTitle = '修改拆纱单价基础资料'
        pageData.showAdd = true
      }
      //判断是否填写了中文
      const isChiese = (value: string, cb: Function) => {
        return new Promise<void>((resolve) => {
          if (window.encodeURI(value).indexOf('%') !== -1) {
            cb('填写的值只能是英文数字组合或英文，数字！')
          }
          resolve()
        })
      }
      //input离开焦点 将小写转大写
      const inputBlur = () => {
        dataForm.unit = dataForm.unit.toUpperCase()
      }
      //导出
      const exports = () => {
        // if (gridOption.value.getSelectedRows().length === 0) {
        //   Message.error('请先勾选')
        //   return
        // } else {
        // let idList: any = []
        // gridOption.value.getSelectedRows().forEach(function (o: any) {
        //   idList.push(o['id'])
        // })
        // //将表头拼接出来
        // let head =
        //   '<th>员工工号</th><th>员工姓名</th><th>织造序号</th><th>机台号</th><th>坯布编号</th><th>坯布名称</th><th>验布日期</th><th>匹号</th><th>次布重量</th><th>验后重量</th><th>工价</th><th>金额</th>'
        // //拿到当前表格数据与勾选的行做筛选

        // let nowRow = pageData.tableList.filter(function (o) {
        //   return (
        //     gridOption.value
        //       .getSelectedRows()
        //       .map((o: any) => {
        //         return o.id
        //       })
        //       .indexOf(o['id']) !== -1
        //   )
        // })
        // let body = ''
        // nowRow.forEach(function (o) {
        //   body +=
        //     '<tr><td>' + (o['checkStaffCode'] == undefined ? '' : o['checkStaffCode']) + '</td>'
        //   body += '<td>' + (o['checkStaff'] == undefined ? '' : o['checkStaff']) + '</td>'
        //   body +=
        //     '<td>' +
        //     (o['weavingSerialNumber'] == undefined ? '' : o['weavingSerialNumber']) +
        //     '</td>'
        //   body += '<td>' + (o['machine'] == undefined ? '' : o['machine']) + '</td>'
        //   body += '<td>' + (o['greigeCode'] == undefined ? '' : o['greigeCode']) + '</td>'
        //   body += '<td>' + (o['greigeName'] == undefined ? '' : o['greigeName']) + '</td>'
        //   body += '<td>' + (o['billDate'] == undefined ? '' : o['billDate']) + '</td>'
        //   body += '<td>' + (o['horses'] == undefined ? '' : o['horses']) + '</td>'
        //   body += '<td>' + (o['fabricWeight'] == undefined ? '' : o['fabricWeight']) + '</td>'
        //   body += '<td>' + (o['actualWeight'] == undefined ? '' : o['actualWeight']) + '</td>'
        //   body += '<td>' + (o['unitPrice'] == undefined ? '' : o['unitPrice']) + '</td>'
        //   body += '<td>' + (o['amount'] == undefined ? '' : o['amount']) + '</td>'
        //   body += '</tr>'
        // })
        // tableToXlsx(head, '值机件资查询', body)
        // console.log(table)
        // EXELTABLE(tableColumns, pageData.tableList, '值机件资查询')
        // }
        post({
          url: '/pieceData/dutymachineSalary/getCheckClothWageExport',
          data: {
            userCode: pageData.checkStaffCode,
            userName: pageData.checkStaff,
            greyCode: pageData.greigeCode,
            greyName: pageData.greigeName,
            beginDate: pageData.billDate,
            endDate: pageData.billDate2,
          },
        }).then(({ data, code }: any) => {
          if (code === 200) {
            data.push(...pageData.hejishuzu)
            EXELTABLE(tc, data, '值机件资查询')
          }
        })
      }

      function tableToXlsx(head: any, filename: any, body: any) {
        const uri = 'data:application/vnd.ms-excel;base64,',
          template = `<html>
            <head><meta charset="UTF-8"></head>
            <body><table border="1"><tr>${head}</tr>${body}</table></body>
        </html>`

        const a = document.createElement('a')
        a.href = uri + window.btoa(unescape(encodeURIComponent(template)))
        a.download = filename
        a.click()
        document.removeChild(a)
      }

      //模板下载
      const downloadHandler = () => {
        axios
          .get(baseURL + '/pdm/disassemblePrice/uploadModel', {
            responseType: 'blob',
            headers: {
              token: sessionStorage.getItem('USER-TOKEN-KEY'),
            },
          })
          .then((res) => {
            if (res.status === 200) {
              filedownload(res.data, '拆纱单价.xlsx')
            }
          })
      }
      //导入
      const importHandler = () => {
        const inputEle: HTMLInputElement = document.createElement('input')
        inputEle.type = 'file'
        inputEle.id = 'fileUploadExcel'
        inputEle.accept =
          'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'
        inputEle.addEventListener('change', (e) => {
          const formData = new FormData()
          if (inputEle.files !== null) {
            formData.append('file', inputEle.files[0] || '')
          } else {
            Message.warning('未选择文件！')
            return
          }
          pageData.pageLoading = true
          axios
            .post(baseURL + '/pdm/disassemblePrice/importModelData', formData, {
              headers: {
                'Content-Type': 'multipart/form-data',
                token: sessionStorage.getItem('USER-TOKEN-KEY'),
              },
            })
            .then((result) => {
              if (result.data['code'] === 200) {
                Message.success('导入成功')
              } else {
                Message.error(result.data.message)
              }
            })
            .finally(() => {
              pageData.pageLoading = false
              doRefresh()
            })
        })
        inputEle.click()
      }
      const handleChange = (_data: any) => {
        table.handleSuccess(_data)
      }
      const defaultColDef = {
        sortable: true,
        resizable: true,
        filter: true,
        // flex: 1
      }
      //下拉框得到焦点 坯布编号
      const focusSel1 = () => {
        selCxAll1({ greigeCode: '' })
      }

      //下拉数据 坯布编号
      const options1 = ref<any>(pageData.pbList)
      const loading1 = ref(false)
      const handleSearch1 = (value: any) => {
        if (value) {
          const ob = { greigeCode: value }
          loading1.value = true
          selCxAll1(ob)
          options1.value = pageData.pbList
          loading1.value = false
        } else {
          options1.value = []
        }
      }
      //下拉框查询 坯布编号
      function selCxAll1(val: any) {
        post({
          url: '/product/pdGreyInformation/selectpdGreyInformation',
          data: val,
        }).then(({ data, code }: any) => {
          if (code === 200) {
            pageData.pbList = data
          } else {
            Message.error({
              content: '查询失败！',
              duration: 5000,
            })
          }
        })
      }
      //根据坯布编号带出坯布名称
      const focusSel2 = () => {
        if (pageData.greigeCode == '' || pageData.greigeCode == null) {
          pageData.greigeName = ''
          Message.error('请先选择坯布编号！')
          return
        } else if (
          pageData.greigeCode != '' &&
          pageData.greigeCode != null &&
          pageData.greigeCode != undefined
        ) {
          post({
            url: '/product/pdGreyInformation/selectpdGreyInformation',
            data: {
              id: pageData.greigeCode,
            },
          }).then(({ data, code }: any) => {
            if (code === 200) {
              pageData.pbmcList = data
            }
          })
        }
      }
      const pbChange = (val: any) => {
        if (pageData.greigeCode == '') {
          pageData.greigeName = ''
          return
        }
        let list = pageData.pbList.filter(function (o: any) {
          return o['id'] == val
        })
        pageData.greigeName = list[0]['greigeName']
      }

      // 获取公司列表
      const getFirmGroup = () => {
        get({
          url: '/org/firmGroup/getTreeFirmGroup',
        }).then(({ code, data }) => {
          if (code === 200) {
            pageData.gsList = data
          }
        })
      }

      //下拉框得到焦点  员工姓名
      const focusSel3 = () => {
        selCxAll3({ checkStaff: '', checkStaffCode: '' })
      }
      //下拉数据  员工姓名
      const options3 = ref<any>(pageData.xmList)
      const loading3 = ref(false)
      const handleSearch3 = (value: any) => {
        if (value) {
          const ob = { checkStaff: value, checkStaffCode: value }
          loading3.value = true
          selCxAll3(ob)
          options3.value = pageData.xmList
          loading3.value = false
        } else {
          options3.value = []
        }
      }
      //下拉框查询  员工姓名
      function selCxAll3(val: any) {
        post({
          url: 'org/employee/getFieldValue',
          data: val,
        }).then(({ data, code }: any) => {
          if (code === 200) {
            pageData.xmList = data
          } else {
            Message.error({
              content: '查询失败！',
              duration: 5000,
            })
          }
        })
      }
      const localeText1: any = ref(localeText)
      const huiche = () => {
        doRefresh()
      }
      const onSelect = (dateString: any) => {
        if (dateString[0]) {
          const d1 = new Date(dateString[0])
          const d2 = new Date(dateString[1])
          if (d1 > d2) {
            dateString.reverse()
          }
        }
        pageData.billDate = dateString[0]
        pageData.billDate2 = dateString[1]
      }
      const onClear = () => {
        pageData.billDate = ''
        pageData.billDate2 = ''
      }
      // :items="['查询', '导出']"
      const permissionStore = usePermission()
      if (permissionStore.hasPermisson('zjjzcx.cx')) {
        pageData.btnList.push('查询')
      }
      if (permissionStore.hasPermisson('zjjzcx.dc')) {
        pageData.btnList.push('导出')
      }

      const countRow=(data: any)=> {
        const totalObj = {
          checkWeight: 0, //值机重量
          fabricWeight: 0, //个人次布重量
          posteriorWeight: 0, //个人验后重量
          weaverMoney: 0, //值机金额
          subsidyMoney: 0, //补贴金额
        }
        data.forEach((item: any) => {
          if (!item.checkWeight) item.checkWeight = 0
          if (!item.fabricWeight) item.fabricWeight = 0
          if (!item.posteriorWeight) item.posteriorWeight = 0
          if (!item.weaverMoney) item.weaverMoney = 0
          if (!item.subsidyMoney) item.subsidyPrice = 0
          totalObj.checkWeight += Number(item.checkWeight)
          totalObj.fabricWeight += Number(item.fabricWeight)
          totalObj.posteriorWeight += Number(item.posteriorWeight)
          totalObj.weaverMoney += Number(item.weaverMoney)
          totalObj.subsidyMoney += Number(item.subsidyMoney)
        })
        const totalMoney = toFixedNum(totalObj.weaverMoney + totalObj.subsidyMoney)
        const newRows = [
          {
            checkWeight: toFixedNum(totalObj.checkWeight),
            fabricWeight: toFixedNum(totalObj.fabricWeight),
            posteriorWeight: toFixedNum(totalObj.posteriorWeight),
            weaverMoney: toFixedNum(totalObj.weaverMoney),
            subsidyMoney: toFixedNum(totalObj.subsidyMoney),
          },
        ]
        gridOption.value.setPinnedBottomRowData(newRows)
        pageData.hejishuzu = newRows
      }

      //筛选
      const FilterChangeds = (params: any) => {
        let data: any = {
          list: [],
        }
        params.api.forEachNodeAfterFilter((row: any) => {
          data.list.push(row.data)
        })
        countRow(data.list)
      }
      return {
        FilterChangeds,
        countRow,
        onSelect,
        onClear,
        huiche,
        focusSel2,
        getFirmGroup,
        pbChange,
        localeText1,
        editHandler,
        deleteHandler,
        sideOk,
        formRef,
        dataForm,
        addHandler,
        selectedRowKeys,
        pagination,
        tableColumns,
        table,
        rowKey,
        pageData,
        queryData,
        selectHandler,
        isChiese,
        inputBlur,
        exports,
        options3,
        loading3,
        handleSearch3,
        focusSel3,
        downloadHandler,
        importHandler,
        options1,
        loading1,
        handleSearch1,
        focusSel1,
        headerShow,
        handleChange,
        PageSize,
        change1,
        defaultColDef,
        tc,
        gridOption,
        gridReady,
        total,
        page,
        size,
        permissionStore,
        pagingList1,
      }
    },
    components: { Toolbar, PageTabelLayout },
  }
</script>
<style scoped lang="less">
  :deep(.arco-picker input) {
    padding-left: 0 !important;
  }

  :deep(.arco-picker) {
    padding-left: 0 !important;
  }

  :deep(.arco-picker-separator) {
    padding: 0 !important;
  }
</style>
